<?php
namespace app\admin\controller;
use app\admin\controller\Base;
use think\Controller;
use think\Db;
use think\Request;
use think\facade\Env;
use think\facade\Session;
// use app\admin\Model\Gkdata;
class Orders extends Base
{
    public function index()
    {
        $data=Db::table('orders')->order("oid","DESC")->paginate(10);
        $this->assign('data',$data);
        return $this->fetch();
    }
    public function search(){
        $request=new request();
        $code= trim($request->post("code"));
        $data=Db::table('orders')->where('code',$code)->paginate(10);
        $this->assign('data',$data);
        return $this->fetch("index");
    }    
    public function orderindex()
    {
        $request=new request();
        $oid= intval($request->get("oid"));
        $data=Db::table('orderone')->where('oid',$oid)->paginate(10);
        $this->assign('data',$data);
        return $this->fetch();
    }

    public function lookpage(){
        $request=new request();
        $ooid= intval($request->get("ooid"));
        $data=Db::name('orderone')->where('ooid',$ooid)->find();       
        $this->assign('data',$data);
        return $this->fetch();
    }
   
    public function delorders()
    {

        $request=new request();
        $oid=$request->get("id");
        $da=Db::name('orders')->delete($oid);
        if($da){
            $this->success('删除成功', 'orders/index');
        }
        else{
            return $this->error('删除失败');
        }
    }
    public function delorderone()
    {

        $request=new request();
        $ooid=$request->get("id");
        $da=Db::name('orderone')->delete($ooid);
        if($da){
            $this->success('删除成功');
        }
        else{
            return $this->error('删除失败');
        }
        return;
    }



}
